
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Employee;
import cn.edu.scau.cmi.hombio.domain.MedicineTake;
import cn.edu.scau.cmi.hombio.domain.MedicineTakeDetail;
import cn.edu.scau.cmi.hombio.domain.Task;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class MedicineTakeServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected MedicineTakeService service;

	/**
	 * Instantiates a new MedicineTakeServiceTest.
	 *
	 */
	public MedicineTakeServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Return all MedicineTake entity
	* 
	 */
	@Test
	public void findAllMedicineTakes() {
		// TODO: JUnit - Populate test inputs for operation: findAllMedicineTakes 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<MedicineTake> response = null;
		response = service.findAllMedicineTakes(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllMedicineTakes
	}

	/**
	 * Operation Unit Test
	* Save an existing Employee entity
	* 
	 */
	@Test
	public void saveMedicineTakeEmployeeByPharmacistId() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineTakeEmployeeByPharmacistId 
		Integer id = 0;
		Employee related_employeebypharmacistid = new cn.edu.scau.cmi.hombio.domain.Employee();
		MedicineTake response = null;
		response = service.saveMedicineTakeEmployeeByPharmacistId(id, related_employeebypharmacistid);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineTakeEmployeeByPharmacistId
	}

	/**
	 * Operation Unit Test
	* Save an existing Employee entity
	* 
	 */
	@Test
	public void saveMedicineTakeEmployeeByTakerId() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineTakeEmployeeByTakerId 
		Integer id_1 = 0;
		Employee related_employeebytakerid = new cn.edu.scau.cmi.hombio.domain.Employee();
		MedicineTake response = null;
		response = service.saveMedicineTakeEmployeeByTakerId(id_1, related_employeebytakerid);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineTakeEmployeeByTakerId
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findMedicineTakeByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findMedicineTakeByPrimaryKey 
		Integer id_2 = 0;
		MedicineTake response = null;
		response = service.findMedicineTakeByPrimaryKey(id_2);
		// TODO: JUnit - Add assertions to test outputs of operation: findMedicineTakeByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineTake entity
	* 
	 */
	@Test
	public void deleteMedicineTake() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineTake 
		MedicineTake medicinetake = new cn.edu.scau.cmi.hombio.domain.MedicineTake();
		service.deleteMedicineTake(medicinetake);
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineTakeDetail entity
	* 
	 */
	@Test
	public void deleteMedicineTakeMedicineTakeDetails() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineTakeMedicineTakeDetails 
		Integer medicinetake_id = 0;
		Integer related_medicinetakedetails_id = 0;
		MedicineTake response = null;
		response = service.deleteMedicineTakeMedicineTakeDetails(medicinetake_id, related_medicinetakedetails_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineTakeMedicineTakeDetails
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineTakeDetail entity
	* 
	 */
	@Test
	public void saveMedicineTakeMedicineTakeDetails() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineTakeMedicineTakeDetails 
		Integer id_3 = 0;
		MedicineTakeDetail related_medicinetakedetails = new cn.edu.scau.cmi.hombio.domain.MedicineTakeDetail();
		MedicineTake response = null;
		response = service.saveMedicineTakeMedicineTakeDetails(id_3, related_medicinetakedetails);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineTakeMedicineTakeDetails
	}

	/**
	 * Operation Unit Test
	* Load an existing MedicineTake entity
	* 
	 */
	@Test
	public void loadMedicineTakes() {
		Set<MedicineTake> response = null;
		response = service.loadMedicineTakes();
		// TODO: JUnit - Add assertions to test outputs of operation: loadMedicineTakes
	}

	/**
	 * Operation Unit Test
	* Delete an existing Task entity
	* 
	 */
	@Test
	public void deleteMedicineTakeTask() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineTakeTask 
		Integer medicinetake_id_1 = 0;
		Integer related_task_id = 0;
		MedicineTake response = null;
		response = service.deleteMedicineTakeTask(medicinetake_id_1, related_task_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineTakeTask
	}

	/**
	 * Operation Unit Test
	* Return a count of all MedicineTake entity
	* 
	 */
	@Test
	public void countMedicineTakes() {
		Integer response = null;
		response = service.countMedicineTakes();
		// TODO: JUnit - Add assertions to test outputs of operation: countMedicineTakes
	}

	/**
	 * Operation Unit Test
	* Delete an existing Employee entity
	* 
	 */
	@Test
	public void deleteMedicineTakeEmployeeByPharmacistId() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineTakeEmployeeByPharmacistId 
		Integer medicinetake_id_2 = 0;
		Integer related_employeebypharmacistid_id = 0;
		MedicineTake response = null;
		response = service.deleteMedicineTakeEmployeeByPharmacistId(medicinetake_id_2, related_employeebypharmacistid_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineTakeEmployeeByPharmacistId
	}

	/**
	 * Operation Unit Test
	* Save an existing Task entity
	* 
	 */
	@Test
	public void saveMedicineTakeTask() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineTakeTask 
		Integer id_4 = 0;
		Task related_task = new cn.edu.scau.cmi.hombio.domain.Task();
		MedicineTake response = null;
		response = service.saveMedicineTakeTask(id_4, related_task);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineTakeTask
	}

	/**
	 * Operation Unit Test
	* Delete an existing Employee entity
	* 
	 */
	@Test
	public void deleteMedicineTakeEmployeeByTakerId() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineTakeEmployeeByTakerId 
		Integer medicinetake_id_3 = 0;
		Integer related_employeebytakerid_id = 0;
		MedicineTake response = null;
		response = service.deleteMedicineTakeEmployeeByTakerId(medicinetake_id_3, related_employeebytakerid_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineTakeEmployeeByTakerId
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineTake entity
	* 
	 */
	@Test
	public void saveMedicineTake() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineTake 
		MedicineTake medicinetake_1 = new cn.edu.scau.cmi.hombio.domain.MedicineTake();
		service.saveMedicineTake(medicinetake_1);
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
